package ${ControllerCompletePackageName};

import ${ServiceCompleteClassFileName};
import ${EntityCompleteClassFileName};
import com.change.core.page.Page;
import com.change.dto.req.Query${EntityClassFileName}Req;
import com.change.dto.req.Save${EntityClassFileName}Req;
import com.change.dto.resp.Query${EntityClassFileName}Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;

/**
* @author ${Author}
* @date  ${Date}
*/
@Api(value = "${ControllerClassFileName}", tags = "")
@Slf4j
@RestController
@RequestMapping(value = "/api/${EntityLowerName}")
public class ${ControllerClassFileName} {
        private final ${ServiceClassFileName} ${ServiceInstName};

        public ${ControllerClassFileName}(${ServiceClassFileName} ${ServiceInstName}) {
                this.${ServiceInstName} = ${ServiceInstName};
        }

        @ApiImplicitParams({
        @ApiImplicitParam(name = "current", value = "当前页", defaultValue = "1"),
        @ApiImplicitParam(name = "size", value = "每页数量", defaultValue = "100")
        })
        @ApiOperation(value = "分页查询")
        @GetMapping("/page")
        public Page<List<Query${EntityClassFileName}Resp>> page(@ApiIgnore Page page, Query${EntityClassFileName}Req req) {
                return ${ServiceInstName}.getPage(page, req);
        }

        @ApiOperation(value = "详情")
        @GetMapping("/detail/{id}")
        public Query${EntityClassFileName}Resp detail(@PathVariable Integer id) {
                return ${ServiceInstName}.detail(id);
        }

        @ApiOperation(value = "新增")
        @PostMapping("/save")
        public ${EntityClassFileName} save(@RequestBody Save${EntityClassFileName}Req req) {
                return ${ServiceInstName}.save(req);
        }

        @ApiOperation(value = "修改")
        @PostMapping("/update")
        public ${EntityClassFileName} update(@RequestBody Save${EntityClassFileName}Req req) {
                return ${ServiceInstName}.update(req);
        }

        @ApiOperation(value = "删除")
        @PostMapping("/delete/{id}")
        public Integer delete(@PathVariable Integer id) {
                return ${ServiceInstName}.delete(id);
        }

}